package com.tbit.uqbike.object.pojo.vo;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.tbit.uqbike.constant.CsvConstant;
import com.tbit.uqbike.webmanager.util.csv.annotations.Csv;
import com.tbit.uqbike.webmanager.util.csv.annotations.Sum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 欠款历史表
 *
 * @Author:BUGTian
 * @DATE: 2022/11/14
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class ArrearsLogDownLoadVo {
    /**
     * 主键
     */
    @TableId(type = IdType.AUTO)
    private Long arrearsId;
    /**
     * 用户id
     */
    private Integer userId;
    /**
     * 用户手机号码
     */
    @Csv(name = "用户手机号码", type = CsvConstant.CSV_TYPE_WITHOUT)
    private String userPhone;
    /**
     * 姓名
     */
    private String userName;
    /**
     * 运营区域id
     */
    private Integer accountId;
    /**
     * 品牌id
     */
    private Integer brandId;
    /**
     * 运营区域名称
     */
    @Csv(name = "运营区域名称", type = CsvConstant.CSV_TYPE_WITHOUT)
    private String accountName;
    /**
     * 业务订单号
     */
    @Csv(name = "业务订单号", type = CsvConstant.CSV_TYPE_WITHOUT)
    private String businessNO;
    /**
     * 类型（1：欠款，2：补交）
     */
    @Csv(name = "类型", keys = {"1", "2"}, values = {"欠款", "补交"}, type = CsvConstant.CSV_TYPE_WITHOUT)
    private Integer dataType;
    /**
     * 变动类型 1：骑行欠款，2：人工修改订单欠款，3：礼品卡抵扣，4：用户充值，5：人工修改订单抵扣 6：余额补交
     */
    @Csv(name = "变动类型", keys = {"1", "2", "3", "4", "5", "6"}, values = {"骑行欠款", "人工修改订单欠款", "礼品卡抵扣", "用户充值", "人工修改订单抵扣", "余额补交"}, type = CsvConstant.CSV_TYPE_WITHOUT)
    private Integer makeUpType;
    /**
     * 变动金额
     */

    private Integer changeMoney;
    /**
     * 初始金额
     */

    private Integer startMoney;
    /**
     * 现欠款金额
     */

    private Integer newArrearsMoney;
    /**
     * 变动时间
     */
    private Long changeTime;


    @Csv(name = "变动时间", type = CsvConstant.CSV_TYPE_WITHOUT)
    private String changeTimeStr;
    @Sum
    @Csv(name = "金额", type = CsvConstant.CSV_TYPE_WITHOUT)
    private BigDecimal changeMoneyBigDecimal;
    @Csv(name = "原欠款金额", type = CsvConstant.CSV_TYPE_WITHOUT)
    private BigDecimal startMoneyBigDecimal;
    @Csv(name = "现欠款金额", type = CsvConstant.CSV_TYPE_WITHOUT)
    private BigDecimal newArrearsMoneyBigDecimal;

    /**
     * 商户订单号
     */
    @Csv(name = "商户订单号", type = CsvConstant.CSV_TYPE_WITHOUT)
    private String merchantNO;
    /**
     * 操作人id
     */
    private Integer operatorId;
    /**
     * 操作人名称
     */
    @Csv(name = "操作人", type = CsvConstant.CSV_TYPE_WITHOUT)
    private String operatorName;
    /**
     * 备注
     */
    private String remark;
    /**
     * 更改备注
     */
    @Csv(name = "订单修改备注", type = CsvConstant.CSV_TYPE_WITHOUT)
    private String changeRemark;


    public String getChangeTimeStr() {
        return DateUtil.format(new Date(this.changeTime), "yyyy-MM-dd HH:mm:ss");
    }

    public BigDecimal getChangeMoneyBigDecimal() {
        return new BigDecimal(this.changeMoney).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP);
    }

    public BigDecimal getStartMoneyBigDecimal() {
        return new BigDecimal(this.startMoney).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP);
    }

    public BigDecimal getNewArrearsMoneyBigDecimal() {
        return new BigDecimal(this.newArrearsMoney).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP);
    }
}
